#coding:utf-8

import cv2
import numpy as np
# import random

img = cv2.imread("lena.bmp")
code = cv2.imread("code.bmp")
w,h = img.shape[:2]
# print w,h
for i in range(w):
    for j in range(h):
        if img[i,j,2] %2 != 0:
            img[i,j,2] = img[i,j,2]+1 if img[i,j,2] <2 else img[i,j,2]-1

# cv2.imwrite("quanou.bmp",img)
for i in range(w):
    for j in range(h):
        if code[i,j,0] == 0 and code[i,j,1] == 0 and code[i,j,2] == 0:
            img[i,j,2] += 1

cv2.imwrite("final.bmp",img)
